/*
 * Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
 *
 * Licensed under the Mulan PSL v2.
 * You can use this file according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of the License at
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
 * FOR MORE DETAILS.
 */

#pragma once

#include "DataStructure/Common/Id.h"

#include "DBManager/Common/DBManagerExport.h"
#include "DBManager/Common/DBManagerNamespace.h"

SG_DBMANAGER_NAMESPACE_OPEN

/**
 * @brief    存储汇总表内的ID映射数据， 包括索引和类型
 *
 * @tparam Type
 * @author   wuxingchuang
 * @date     2025.02.26
 */
template <typename Type>
struct SummaryInfo
{
    SG::DataStructure::Common::Id  m_id;
    Type                           m_type;
    SG::DataStructure::Common::I64 m_index;

    SummaryInfo ()
    {}

    SummaryInfo (SG::DataStructure::Common::Id id, const Type type, const SG::DataStructure::Common::I64 index)
        : m_id (id), m_type (type), m_index (index)
    {}

    SummaryInfo (SG::DataStructure::Common::Id id, const Type type) : m_id (id), m_type (type), m_index (0)
    {}

    bool operator< (const SummaryInfo& rhs) const
    {
        return m_id < rhs.m_id;
    }
};

/**
 * @brief    存储汇总表内的ID与类型的映射
 *
 * @tparam Type
 * @author   wuxingchuang
 * @date     2025.02.26
 */
template <typename Type>
struct MultiSummaryInfo
{
    SG::DataStructure::Common::Id m_sId;
    std::vector<Type>             m_type;

    MultiSummaryInfo ()
    {}

    MultiSummaryInfo (SG::DataStructure::Common::Id sid, const std::vector<Type> type) : m_sId (sid), m_type (std::move (type))
    {}

    bool operator< (const MultiSummaryInfo& rhs) const
    {
        return m_sId < rhs.m_sId;
    }
};

struct SummaryIDENTITY
{
    SG::DataStructure::Common::Id  m_sId;
    SG::DataStructure::Common::I64 m_beginIndex;
    SG::DataStructure::Common::I64 m_length;
};

/**
 * @brief    二级缓存数据结构
 *
 * @author   wuxingchuang
 * @date     2025.07.10
 */
struct TwoLayersData
{
    SG::DataStructure::Common::I64              m_id = 0;
    std::vector<SG::DataStructure::Common::I64> m_subs;

    TwoLayersData () : m_id (0) {};

    TwoLayersData (SG::DataStructure::Common::I64 p, std::vector<SG::DataStructure::Common::I64> subs)
        : m_id (p), m_subs (std::move (subs))
    {}

    bool operator< (const TwoLayersData& rhs) const
    {
        return m_id < rhs.m_id;
    }
};
SG_DBMANAGER_NAMESPACE_CLOSE